<template>
  <!--  <svgcion  iconname='b'> -->
  <svg :class="svgClass" :style="{ fill: color }" aria-hidden="true">
    <!--  引用对象svg文件 -->
    <use :xlink:href="iconName" />
    <!-- iconName 放可访问的链接 -->
  </svg>
</template>

<script>
export default {
  props: {
    color: {
      type: String,
      default: 'black',
    },
    iconClass: {
      type: String,
      required: true,
    },
    className: {
      type: String,
      default: '',
    },
  },
  computed: {
    iconName() {
      return `#icon-${this.iconClass}`;
    },
    svgClass() {
      if (this.className) {
        return 'svg-icon ' + this.className;
      } else {
        return 'svg-icon';
      }
    },
    styleExternalIcon() {
      return {
        mask: `url(${this.iconClass}) no-repeat 50% 50%`,
        '-webkit-mask': `url(${this.iconClass}) no-repeat 50% 50%`,
      };
    },
  },
};
</script>

<style lang="scss" scoped></style>
